using Microsoft.Practices.EnterpriseLibrary.Validation;
using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;

using System;
using System.Runtime.Serialization;


namespace Agron.Data.Contracts
{
    /// <summary>
    /// Defines the data contract for a Session entity.
    /// </summary>
    [Serializable]
    [DataContract(Namespace = "http://schemas.udlap.mx/Agron/Session")]
    public class Session
    {
        private Guid _ownerId;
        private int _sessionId;
        private bool _recurrent;
        private bool _requiresPassword;
        private string _subject;
        private string _description;
        private string _sessionPassword;
        private DateTime _start;
        private DateTime _finish;
        private DateTime _actualFinish;

        /// <summary>
        /// Initializes a new instance of the <see cref="Session"/> class.
        /// </summary>
        public Session() { }

        /// <summary>
        /// Gets or sets the session id.
        /// </summary>
        /// <value>A <see cref="Guid"/> that contains the session id.</value>
        [DataMember(IsRequired = true)]
        public int SessionId { get { return this._sessionId; } set { this._sessionId = value; } }

        /// <summary>
        /// Gets or sets the owner id.
        /// </summary>
        /// <value>The owner id.</value>
        [DataMember(IsRequired = true)]
        public Guid OwnerId { get { return this._ownerId; } set { this._ownerId = value; } }

        /// <summary>
        /// Gets or sets the subject.
        /// </summary>
        /// <value>A <see cref="String"/> that contains the subject.</value>
        [StringLengthValidator(1, 50, MessageTemplateResourceName = "SessionSubjectRequired", MessageTemplateResourceType = typeof(Properties.Resources))]
        [ValidatorComposition(CompositionType.And)]
        [NotNullValidator(MessageTemplateResourceName = "SessionSubjectRequired", MessageTemplateResourceType = typeof(Properties.Resources))]
        [DataMember(IsRequired = true)]
        public string Subject { get { return this._subject; } set { this._subject = value; } }

        /// <summary>
        /// Gets or sets the start date time.
        /// </summary>
        /// <value>A <see cref="DateTime"/> that contains the start date time.</value>
        [NotNullValidator(MessageTemplateResourceName = "SessionStartRequired", MessageTemplateResourceType = typeof(Properties.Resources))]
        [DataMember(IsRequired = true)]
        public DateTime Start { get { return this._start; } set { this._start = value; } }

        /// <summary>
        /// Gets or sets end date time
        /// </summary>
        /// <value>A <see cref="DateTime"/> that contains the end date time.</value>
        [NotNullValidator(MessageTemplateResourceName = "SessionFinishRequired", MessageTemplateResourceType = typeof(Properties.Resources))]
        [DataMember(IsRequired = true)]
        public DateTime Finish { get { return this._finish; } set { this._finish = value; } }

        /// <summary>
        /// Gets or sets the actual finish.
        /// </summary>
        /// <value>The actual finish.</value>
        [DataMember]
        public DateTime ActualFinish { get { return this._actualFinish; } set { this._actualFinish = value; } }

        /// <summary>
        /// Gets or sets the session's description.
        /// </summary>
        /// <value>A <see cref="String"/> that contains the description.</value>
        [StringLengthValidator(0, 50, MessageTemplateResourceName = "SessionDescriptionValidation", MessageTemplateResourceType = typeof(Properties.Resources))]
        [DataMember(IsRequired = false)]
        public string Description { get { return this._description; } set { this._description = value; } }

        /// <summary>
        /// Gets or sets a value indicating whether this <see cref="Session"/> is recurrent.
        /// </summary>
        /// <value><c>true</c> if recurrent; otherwise, <c>false</c>.</value>
        [DataMember(IsRequired = false)]
        public bool Recurrent { get { return this._recurrent; } set { this._recurrent = value; } }

        /// <summary>
        /// Gets or sets a value indicating whether [requires password].
        /// </summary>
        /// <value><c>true</c> if [requires password]; otherwise, <c>false</c>.</value>
        [DataMember(IsRequired = false)]
        public bool RequiresPassword { get { return this._requiresPassword; } set { this._requiresPassword = value; } }

        /// <summary>
        /// Gets or sets the session password.
        /// </summary>
        /// <value>The session password.</value>
        [DataMember(IsRequired = false)]
        public string Password { get { return this._sessionPassword; } set { this._sessionPassword = value; } }
    }
}
